﻿using Mite;


namespace Mite.CSharpExample
{



    public class Migration1 :MigrationBase
    {
        public Migration1(MiteEnvironment environment)
            : base(environment)
        {

        }

        public override uint Version
        {
            get { return 1; }
        }

        protected override void Up()
        {
            
            CreateTable("activity_participation",
                    new Int32("registration_id", false),
                    new Int32("activity_id", false)
               );
            CreateTable("activitygroup",
                new Int32("Id", true, true, false, true),
                new String("GroupName", 255, true),
                new Int32("ActivityGroupType", true),
                new String("Instructions", 255, true),
                new Int32("Conference", true)
           );
            CreateTable("agendaitem",
                     new Int32("Id", true, true, false, true),
                     new DateTime("StartTime"),
                     new DateTime("EndTime"),
                     new String("Name"),
                     new StringFixedLength("Description", 255), //Change to handle text
                     new Int32("Event", false, false, true, false)
                );
            CreateTable("answer",
                new Int32("Id", false),
                new String("Value"),
                new Int32("Registration", true),
                new Int32("Question", true)

                );
            CreateTable("attendee_status",
                     new Int32("Id", true, true, false, true),
                     new String("Value"),
                     new Int32("Event", true)
                );
            CreateTable("criteria",

                     new Int32("Id", true, true, false, true),
                     new String("Answer"),
                     new Int32("PriceModifier", false, false, true, true));
            CreateTable("dynamicpage",
                new Int32("Id", true, true, false, true),
                new String("Content") //TODO: Change to handle text
                );

            CreateTable("email",
                     new Int32("Id", true, true, false, true),
                     new String("HeaderFilename", 100),
                     new String("FooterFilename", 100),
                     new String("Subject", 90),
                     new String("Body"),
                     new String("EmailAddress", 310)
                );
            CreateTable("event",
                new Int32("Id", true, true, false, true),
                new String("type", 255, false),
                new String("Name"),
                new String("Description"), //TODO: Change to handle Text
                new Decimal("Price", 19),
                new Int32("MaxRegistrants"),
                new DateTime("StartsAt"),
                new DateTime("EndsAt"),
                new String("Location"),
                new DateTime("LastDayToRegister"),
                new Boolean("IsActive"),
                new Int32("RegistrationWizardId"),
                new Int32("Owner"),
                new Int32("ActivityGroup")
                );
            CreateTable("nopay",
                new Guid("Id", false, true, false, true),
                new String("DisplayName", 100),
                new String("Email", 310),
                new Int32("Registration"),
                new Int32("Conference")
                );
            CreateTable("payment",
                     new Int32("transaction_id"),
                     new Int32("registration_id"));

            CreateTable("payment_transaction",
                new Int32("Id", true, true, false, true),
                new String("TransactionId"),
                new Decimal("Amount", 19),
                new String("OriginalTransactionId", 60),
                new Int32("TransactionType")

                );

            CreateTable("price_modifier",
                new Int32("Id", true, true, false, true),
                new String("Name", 50),
                new Decimal("NewPrice", 19),
                new Int32("Event")

                );
            CreateTable("question",
                new Int32("Id", true, true, false, true),
                new String("type", 255, false),
                new String("Label"),
                new String("Explanation"),
                new Boolean("Required"),
                new Int32("SequenceNumber"),
                new Int32("WizardStep"),
                new Int32("SelectType"),
                new Int32("TextMode"),
                new Int32("MaxLength"),
                new DateTime("BeginActiveDates"),
                new DateTime("EndActiveDates")
                );
            CreateTable("registration",
                new Int32("Id", true, false, false, true),
                new Decimal("AmountPaid", 19),
                new Int32("PaymentStatus"),
                new DateTime("SignupAt"),
                new DateTime("CheckedInAt"),
                new Int32("AttendeeStatusId"),
                new Int32("Event")
                );

            CreateTable("select_option",
                new Int32("Id", true, true, false, true),
                new String("Text", 255),
                new String("Value"),
                new Int32("SequenceNumber"),
                new Int32("SelectQuestion")
                );

            CreateTable("users",
                new Int32("Id", true, true, false, true),
                new String("Email")

                );

            CreateTable("wizard",
                new Int32("Id", true, true, false, true),
                new String("Title"),
                new Int32("Event")

                );

            CreateTable("wizard_response_report",
                new Int32("Id", true, true, false, true),
                new String("Name"),
                new Int32("Wizard")
                );
            CreateTable("wizard_response_report_membership",
                new Int32("wizard_response_report_id", false, false, false, true),
                new Int32("question_id", false, false, false, true)

                );
            CreateTable("wizard_step",
                new Int32("Id", true, true, false, true),
                new String("type", 255, false),
                new String("Header"),
                new Int32("SequenceNumber"),
                new String("Description"),
                new Int32("Wizard"),
                new Int32("ActivityGroupId")
                );
        }

        protected override void Down()
        {

            DropTable("activity_participation");
            DropTable("activitygroup");
            DropTable("agendaitem");
            DropTable("answer");
            DropTable("attendee_status");
            DropTable("criteria");
            DropTable("dynamicpage");

            DropTable("email");
            DropTable("event");
            DropTable("nopay");
            DropTable("payment");

            DropTable("payment_transaction");

            DropTable("price_modifier");
            DropTable("question");
            DropTable("registration");

            DropTable("select_option");

            DropTable("users");

            DropTable("wizard");

            DropTable("wizard_response_report");
            DropTable("wizard_response_report_membership");
            DropTable("wizard_step");

        }
    }
    public class Migration2 : MigrationBase
    {
        public Migration2(MiteEnvironment environment)
            : base(environment)
        {

        }

        public override uint Version
        {
            get { return 2; }
        }

        protected override void Up()
        {
            CreateTable("second_table", new Int32("id", true, true, false, true));
        }
        protected override void Down()
        {

        }

    }
}
